
<% provide :header_title, '欢迎访问王志华的博客！' %>
<%= stylesheet_link_tag params[:controller] %>
<%= javascript_include_tag params[:controller] %>
<div class="container-fluid basic">
  <div class="row">
    <div class="col-lg-2 col-sm-3">
      <div class="list-group" id="left-list-group-id">
        <a class="list-group-item <%= 'active' if @active.nil? || @active == 0  %>" href="<%= recommended_reading_path %>">推荐</a>
        <% @blog_sorts.each do |sort| %>
            <a class="list-group-item <%= 'active' if (!@active.nil? && @active==sort.id.to_s)  %> <%= 'disabled' if( sort.posts_count<1 ) %>" href="/classified_query/<%= sort.id%>" name="<%= sort.sort_name %>"><%= sort.sort_name %><span class="badge"><%= sort.posts_count %> </span></a>

            <%end%>
        <a class="list-group-item disabled" href="#">IDEA</a>
      </div>
    </div>
    <div class="col-lg-10 col-sm-9">

      <div class="col-lg-9">
        <% @posts.each do |post| %>
            <div class="blog-line">
            <h1>
              <a href="<%= post_path(post) %>" class="blog-title">
                <%=post.title%>
              </a>
            </h1>
            <h6 class="subtitle"><a href="<%= '' %>" class="author" ><%=post.author%></a>&nbsp;&nbsp;&nbsp;&nbsp;发布于&nbsp;&nbsp;&nbsp;&nbsp;<%= DateTime.parse(post.created_at.to_s).strftime('%y-%m-%d %H:%M:%S').to_s %>
              分属于：<%= !post.blog_sort.nil? ? post.blog_sort.sort_name : '无名英雄' %>
            </h6>
              <textarea id="<%= post.id %>" hidden="hidden"><%= post.content %></textarea>
            <p  id="show-content-<%= post.id %>" class="show-content">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


              <%if post.content.length>150 then%>
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;......更多
              <%end%>
            </p>
            </div>
            <script type="text/javascript">
                $(document).ready(function(){
                    var c = $("#<%= post.id %>").text();
                    $("#show-content-<%= post.id %>").html(c)
                    var $show_content = $("#show-content-<%= post.id %>")

                    $show_content.text( $show_content.text())
                })
            </script>
        <%end%>
      </div>

      <div class="col-lg-3">

      </div>
    </div>
  </div>
</div>
<script type="text/javascript">
    var $tmp =  $("div.list-group > a");
    var className = "active";
    /* 如果有disabled类，这禁用链接，否则为其修改样式并将其他的同类样式删除*/
    $("div#left-list-group-id > a").click(function() {
        if(false == $(this).hasClass("disabled")){
            $(this).addClass(className).siblings().removeClass(className);
        }else{
            $(this).removeAttr("href").removeAttr("onclick");
        }

    });

</script>



